package com.bbva.model.validator;

import java.math.BigDecimal;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.bbva.model.Account;

public class AccountValidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return clazz.equals(Account.class);
	}

	@Override
	public void validate(Object account, Errors errors) {
		if(((Account)account).getCount().compareTo(new BigDecimal(0)) < 0) {
			errors.rejectValue("count", "account.count.nev", "Account count less than 0!");
		}
	}

}
